<extend name="Public/layout"/>

<block name="body">
    <div class="title">
        <h2>{$meta_title}</h2>
    </div>
    <duv class="row">
        <form action="__SELF__" method="post" class="form">
            <div class="form-group">
                <label class="item-label">上级导航<span class="check-tips">（所属的上级导航）</span></label>
                <div class="controls">
                    <select name="pid" class="form-control">
                        <volist name="all_navlink" id="navlink">
                            <option value="{$navlink.id}" 
                                <php>if($navlink['id'] == $info['pid']) echo 'selected="selected"';</php> >
                                {$navlink.title_show}
                            </option>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="item-label">标题<span class="check-tips">（用于后台显示的配置标题）</span></label>
                <div class="controls">
                    <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
                </div>
            </div>
            <div class="form-group">
                <label class="item-label">导航内容模型<span class="check-tips">（导航内容模型）</span></label>
                <div class="controls">
                    <select name="model" class="form-control">
                        <option>请选择模型：</option>
                        <volist name="all_model" id="model">
                            <option value="{$model.id}" 
                                <php>if($model['id'] == $info['model']) echo 'selected="selected"';</php> >
                                {$model.title}
                            </option>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="form-group url <php>if($info['model'] != 1) echo 'hidden';</php>">
                <label class="item-label">链接<span class="check-tips">（U函数解析的URL或者外链）</span></label>
                <div class="controls">
                    <input type="text" class="form-control" name="url" value="{$info.url|default=''}">
                </div>
            </div>
            <div class="form-group content <php>if($info['model'] != 2) echo 'hidden';</php>">
                <label class="item-label">内容<span class="check-tips">（单页模型填写内容）</span></label>
                <div class="controls">
                    <textarea class="form-control" name="content">{$info.content|default=''}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="item-label">图标<span class="check-tips">（导航图标）</span></label>
                <div class="controls">
                    <input type="text" class="form-control" name="icon" value="{$info.icon|default=''}">
                </div>
            </div>
            <div class="form-group">
                <label class="item-label">排序<span class="check-tips">（用于分组显示的顺序）</span></label>
                <div class="controls">
                    <input type="text" class="form-control" name="sort" value="{$info.sort|default=0}">
                </div>
            </div>
            <div class="form-group">
                <input type="hidden" name="id" value="{$info.id|default=''}">
                <button class="btn ajax-post"  type="submit" target-form="form">确 定</button>
                <button class="btn" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            $('select[name="model"]').change(function(){
                var model_id = $(this).val();
                if(model_id == 1){ //超链接
                    $('.url').removeClass('hidden');
                    $('.content').addClass('hidden');
                }else if(model_id == 2){ //单页文档
                    $('.url').addClass('hidden');
                    $('.content').removeClass('hidden');
                }else{
                    $('.url').addClass('hidden');
                    $('.content').addClass('hidden');
                }
            });
        });
    </script>
    <script type="text/javascript">
        var editor_content;
        KindEditor.ready(function(K) {
            editor_content = K.create('textarea[name="content"]', {
                allowFileManager : false,
                themesPath: K.basePath,
                width: '100%',
                height: '500px',
                cssPath : [
                    '__PUBLIC__/zui/css/zui.min.css',
                    '__PUBLIC__/kindeditor/plugins/code/prettify.css'
                ],
                resizeType: 1,
                pasteType : 2,
                urlType : 'absolute',
                items : [
                    'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', 'downremoteimg', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
                    'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink', 'poll', '|', 'about'
                ],
                fileManagerJson : '{:U("Upload/file_manager")}',
                uploadJson : '{:U("Upload/upload")}',
                remoteImgSaveUrl: '{:U("Upload/download")}',
                extraFileUploadParams: {
                    session_id : '{:session_id()}'
                },
                afterBlur: function(){this.sync();},
                autoSaveMode:true,
                autoSaveInterval:100,
                afterCreate: function() {
                    this.loadPlugin('autosave');
                }
            });
        });
    </script>
</block>

